<template>
	<view class="wineshop-container">
		<view class="" style="border-radius: 30rpx;overflow: hidden;background-color: #FFFFFF;">

			<!-- 列表 -->
			<view class="list">
				<view class="list-item" v-for="(item,index) in listData" :key="index">
					<image class="shoping-image" :src="item.f1" mode="aspectFill"></image>
					<view class="list-item-container">
						<view class="title">{{item.goodsName}}</view>
						<view class="tips1">
							<text class="color1">{{item.f2 || ''}}</text>
						</view>
						<!-- <view class="tips2 color1">{{item.standards}}</view> -->
						<view class="tips3 color1">
							<view class="">
								<text><text style="font-size: 24rpx;">￥</text>{{item.sellingPrice}}</text>
								<text class="through" v-if="item.crossedPrice">￥{{item.crossedPrice}}</text>
							</view>
							<view class="submit" v-if="Number(item.maxInventory)>0" @click.stop="handleSubmit(item)">预订</view>
							<view class="submit disabled" v-else>预订</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- empowerShow -->
		<empower @login-success="empowerSuccess" @cancel="empowerShow=false" v-if="empowerShow"></empower>
	</view>
</template>
<script>
	import {
		goodsWeChatList,
		realmName
	} from "@/http/index.js";
	import empower from "@/components/empower";
	export default {
		components: {
			empower
		},
		props: {
			selectorTime: {
				type: Array,
				require: true,
				default: () => []
			}
		},
		data() {
			return {
				empowerShow: false,
				realmName,
				listData: []
			}
		},
		methods: {
			async getList(options) {
				let res = await goodsWeChatList({
					fromOnshowTime: new Date(options[0].replace(/\-/g, "\/")),
					lastOnshowTime: new Date(options[options.length-1].replace(/\-/g, "\/"))
				});
				this.listData = res.data.rows.map(item => {
					item.f1 = realmName + item.f1;
					return item;
				});
			},
			empowerSuccess() {
				this.empowerShow = false;
			},
			handleSubmit(options) {
				let userInfo = uni.getStorageSync('userInfo') || {};
				if (!userInfo || !userInfo.phone) return this.empowerShow = true;
				let data = {
					time: this.selectorTime,
					goodsName: options.goodsName,
					goodsId: options.goodsId,
					standards: options.standards,
					maxInventory: options.maxInventory,
					sellingPrice: options.sellingPrice,
					outTime: this.selectorTime[this.selectorTime.length - 1],
					inTime: this.selectorTime[0],
					imageUrl: options.f1,
					f2: options.f2,
					lastOnshowTime: new Date(options.lastOnshowTime).getTime(),
					fromOnshowTime: new Date(options.fromOnshowTime).getTime()
				};
				uni.navigateTo({
					url: "/homePages/hotel/reserve?options=" + JSON.stringify(data)
				});
			}
		}
	}
</script>
<style lang="scss" scoped>
	.wineshop-container {
		box-sizing: border-box;

		.row-2 {
			margin-top: 24rpx;
			background-color: #FFFFFF;
			border-radius: 30rpx;
			padding: 24rpx;

			.cell-3 {
				//  
				padding-top: 8rpx;

				.tips {
					margin-left: 40rpx;
					margin-top: 24rpx;
					color: #5A5A5A;
					font-size: 24rpx;
					line-height: 33rpx;
				}

				.item {
					color: #1F1F1F;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					margin-top: 24rpx;

					.item-image {
						width: 28rpx;
						height: 28rpx;
						margin-right: 12rpx;
					}
				}
			}

			.cell-2-item-1 {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.title {
					font-size: 32rpx;
					font-weight: 500;
					color: #1F1F1F;
				}

				.tips {
					display: flex;
					align-items: center;

					text {
						margin-right: 8rpx;
						font-size: 24rpx;
						color: #878787;
					}
				}
			}
		}

		.row-1 {
			margin-top: 24rpx;
			background-color: #FFFFFF;
			border-radius: 30rpx;
			padding: 24rpx;

			.cell-1-item-2 {
				display: flex;
				flex-wrap: wrap;

				.item {
					width: 20%;
					display: flex;
					align-items: center;
					justify-content: center;
					flex-direction: column;
					margin-top: 32rpx;

					.item-image {
						width: 40rpx;
						height: 33rpx;
					}

					.item-text {
						color: #5A5A5A;
						font-size: 22rpx;
						white-space: nowrap;
						margin-top: 12rpx;
					}
				}
			}

			.cell-1-item-1 {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.title {
					font-size: 32rpx;
					font-weight: 500;
					color: #1F1F1F;
				}

				.tips {
					display: flex;
					align-items: center;

					text {
						margin-right: 8rpx;
						font-size: 24rpx;
						color: #878787;
					}
				}
			}
		}

		.color1 {
			color: #FD8F19;
		}

		.list {
			// padding: 0 24rpx;
			padding-bottom: 100rpx;

			.list-item {
				display: flex;
				font-size: 24rpx;
				padding: 24rpx 0;

				&+.list-item {
					border-top: 1px solid #EEEEEE;
				}

				.list-item-container {
					flex: 1;

					.title {
						color: #1F1F1F;
						font-size: 32rpx;
						font-weight: bold;
					}

					.tips1 {
						margin: 12rpx 0;
						color: #5A5A5A;

						text {
							&+text {
								margin-left: 10rpx;
							}
						}
					}

					.tips3 {
						position: relative;
						margin-top: 32rpx;
						font-size: 36rpx;
						display: flex;
						align-items: center;
						justify-content: space-between;

						.through {
							color: #C1C1C1;
							font-size: 24rpx;
							text-decoration: line-through;
							margin-left: 12rpx;
						}

						.submit {
							width: 100rpx;
							height: 50rpx;
							background: #FD8F19;
							border-radius: 30rpx;
							line-height: 50rpx;
							text-align: center;
							font-size: 24rpx;
							color: #FFFFFF;
						}

						.disabled {
							background-color: #C1C1C1;
						}
					}
				}

				.shoping-image {
					height: 134rpx;
					min-width: 134rpx;
					max-width: 134rpx;
					border-radius: 30rpx;
					margin-right: 24rpx;
				}

			}
		}

		.tabs {
			display: flex;
			align-items: center;
			justify-content: space-between;

			padding: 24rpx;

			.tabs-u {
				width: 518rpx;
			}

			.tips {
				width: 116rpx;
				height: 50rpx;
				background: #F4F3F8;
				border-radius: 28px;
				display: flex;
				align-items: center;
				justify-content: center;

				font-size: 24rpx;
				color: #5A5A5A;
			}
		}
	}
</style>
